package Demo03.Demo09;


import java.io.*;

public class Test {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("b.txt")));
        int[] ints1 = new int[26];
        int[] ints2 = new int[26];

        char[] c = new char[1];
        int len = reader.read(c);
        while (len != -1) {

            if (c[0] <= 'Z' && c[0] >= 'A') {
                int number = c[0];
                ints1[number - 65]++;
            }
            if (c[0] <= 'z' && c[0] >= 'a') {
                int number = c[0];
                ints2[number - 97]++;
            }
            len = reader.read(c);
        }
        Print(ints1, ints2);
        System.out.print("b.txt文件读取完毕！");
        reader.close();


    }

    private static void Print(int[] ints1, int[] ints2) {
        for (int i = 0; i < 26; i++) {
            if (ints1[i]>0){
                char lowerCase =(char)(i+97);
                System.out.println(lowerCase+"("+ints1[i]+")");
            }
            if (ints2[i]>0){
                char upperCase =(char)(i+65);
                System.out.println(upperCase+"("+ints2[i]+")");
            }
        }
    }
}
